package com.itheima.controller;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import com.itheima.pojo.PageBean;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/emps")
@RestController
public class EmpController
{
   @Autowired
    private EmpService empService;
   @GetMapping
    public Result page( EmpQueryParam empQueryParam){
       PageBean page = empService.page(empQueryParam);
       return Result.success(page);
   }
//   @GetMapping("/{id}")
//    public Result getById(@PathVariable Integer id){
//       Emp emp = empService.getById(id);
//       return Result.success(emp);
//   }
//   @PutMapping
//    public Result update(@RequestBody Emp emp){
//       empService.update(emp);
//       return Result.success();
//   }
   @PostMapping
    public Result add(@RequestBody Emp emp){
       empService.add(emp);
       return Result.success();
   }


}
